{extend name="layout:base" /}

{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">客户信息</div>
        <div class="layui-card-body layui-text">
            <table class="layui-table">
                <thead>
                <tr>
                    <th>客户名称</th>
                    <th>账户余额</th>
                    <th>累计消费</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>{$article.name}</td>
                    <td>{$article.money}
                        <button id="money_reset" class="layui-btn layui-btn-sm layuiadmin-btn-list" lay-tips="‘{$article.name}’账户清零">账户清零</button>
                    </td>
                    <td>{$article.moneypay}
                        <button class="layui-btn layui-btn-sm" lay-tips="‘{$article.name}’充值记录" lay-text="‘{$article.name}’充值记录" lay-href="{:url(('usercz'))}?userID={$article.id}">充值记录</button>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="layui-card">
        <div class="layui-card-header">客户资金变更</div>
        <div class="layui-card-body">
            <div class="layui-tab layui-tab-card">
                <ul class="layui-tab-title">
                    <li class="layui-this">入账</li>
                    <li class="">扣除</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <form class="layui-form">
                            <input type="hidden" name="id" value="{$article.id}" autocomplete="off" class="layui-input" readonly>
                            <input type="hidden" name="typeid" value="0">
                            <div class="layui-row layui-col-space10 layui-form-item">
                                <label class="layui-form-label">金额</label>
                                <div class="layui-input-inline">
                                    <input type="number" name="money" value="" lay-verify="required" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-layout-admin">
                                <div class="layui-input-block">
                                    <div class="layui-footer" style="left: 0;">
                                        <button class="layui-btn" lay-submit="" lay-filter="btnAdd">保存</button>
                                        <a class="layui-btn layui-btn-primary" href="javascript:parent.location.reload();">返回</a>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="layui-tab-item">
                        <form class="layui-form">
                            <input type="hidden" name="id" value="{$article.id}" autocomplete="off" class="layui-input" readonly>
                            <input type="hidden" name="typeid" value="-1">
                            <div class="layui-row layui-col-space10 layui-form-item">
                                <label class="layui-form-label">金额</label>
                                <div class="layui-input-inline">
                                    <input type="number" name="money" value="" lay-verify="required" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-layout-admin">
                                <div class="layui-input-block">
                                    <div class="layui-footer" style="left: 0;">
                                        <button class="layui-btn" lay-submit="" lay-filter="btnAdd">保存</button>
                                        <a class="layui-btn layui-btn-primary" href="javascript:parent.location.reload();">返回</a>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>


</div>

{/block}

{block name="script"}
<script>
    layui.config({
        base: '__STATIC__/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'util', 'form', 'laydate'], function () {
        var $ = layui.$, form = layui.form, layer = layui.layer, table = layui.table, laydate = layui.laydate;
        $uid={$article.id};

        $('#money_reset').click(function () {
            $.post("{:url('money_reset')}",{userID:$uid}, function (result) {
                if (result['code'] == 0) {
                    layer.msg(result['msg'], {icon: 1, time: 1000}, function () {
                        location.reload();
                    });
                } else {
                    layer.msg(result['msg'], {icon: 3, time: 3000});
                }
            });
            return false;
        });

        form.on('submit(btnAdd)', function (data) {
            $.post("{:url('user')}", data.field, function (result) {
                if (result['code'] == 0) {
                    layer.msg(result['msg'], {icon: 1, time: 1000}, function () {
                        location.reload();
                    });
                } else {
                    layer.msg(result['msg'], {icon: 3, time: 3000});
                }
            });
            return false;
        });


    });

</script>
{/block}